package com.kingint.web.portal.base.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kingint.common.unitedresult.K;
import com.kingint.mbg.bas.entity.BasFloor;
import com.kingint.web.portal.base.service.FloorService;
import com.kingint.web.portal.base.service.RoomService;
import com.kingint.web.sys.service.UmsMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @描述：楼层表控制类
 * @作者: wxh
 * @日期: 2020-12-21
 */
@RestController
@RequestMapping("/Floor")
@Api(value = "BasFloorController", description = "楼层表")
@CrossOrigin
public class FloorController {

    @Autowired
    public FloorService basFloorService;
    @Autowired
    public RoomService basRoomService;
    @Autowired
    private UmsMemberService umsMemberService;


    @ApiOperation(value = "根据楼层表名称分页获取楼层表列表")
    @GetMapping("/list")
    public Object getList(BasFloor basFloor){
        basFloor.setHotelId(umsMemberService.getUserHotel());
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("hotel_id",basFloor.getHotelId());
        if (!StringUtils.isEmpty(basFloor.getFloorName())){
            queryWrapper.eq("floor_name",basFloor.getFloorName());
        }
        List<BasFloor> list = basFloorService.list(queryWrapper);
        return K.ok().data(list);
    }

    @ApiOperation(value = "根据编号查询楼层表信息")
    @GetMapping("/{id}")
    public Object getItem(@PathVariable("id") Long id){
        BasFloor basFloor=basFloorService.getById(id);
        return K.ok().data(basFloor);
    }
}